<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE GADTs #-}</span><span>
</span><span id="line-2"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Cmm.Switch.Implement</span><span>
</span><span id="line-3"></span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Cmm.Switch.Implement.html#cmmImplementSwitchPlans"><span class="hs-identifier">cmmImplementSwitchPlans</span></a></span><span>
</span><span id="line-4"></span><span>  </span><span class="hs-special">)</span><span>
</span><span id="line-5"></span><span class="hs-keyword">where</span><span>
</span><span id="line-6"></span><span>
</span><span id="line-7"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-8"></span><span>
</span><span id="line-9"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#"><span class="hs-identifier">GHC.Platform</span></a></span><span>
</span><span id="line-10"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html"><span class="hs-identifier">GHC.Cmm.Dataflow.Block</span></a></span><span>
</span><span id="line-11"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html"><span class="hs-identifier">GHC.Cmm.BlockId</span></a></span><span>
</span><span id="line-12"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.html"><span class="hs-identifier">GHC.Cmm</span></a></span><span>
</span><span id="line-13"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Utils.html"><span class="hs-identifier">GHC.Cmm.Utils</span></a></span><span>
</span><span id="line-14"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Switch.html"><span class="hs-identifier">GHC.Cmm.Switch</span></a></span><span>
</span><span id="line-15"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html"><span class="hs-identifier">GHC.Types.Unique.Supply</span></a></span><span>
</span><span id="line-16"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-17"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html"><span class="hs-identifier">GHC.Utils.Monad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.Monad.html#concatMapM"><span class="hs-identifier">concatMapM</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-18"></span><span>
</span><span id="line-19"></span><span class="hs-comment">--</span><span>
</span><span id="line-20"></span><span class="hs-comment">-- This module replaces Switch statements as generated by the Stg -&gt; Cmm</span><span>
</span><span id="line-21"></span><span class="hs-comment">-- transformation, which might be huge and sparse and hence unsuitable for</span><span>
</span><span id="line-22"></span><span class="hs-comment">-- assembly code, by proper constructs (if-then-else trees, dense jump tables).</span><span>
</span><span id="line-23"></span><span class="hs-comment">--</span><span>
</span><span id="line-24"></span><span class="hs-comment">-- The actual, abstract strategy is determined by createSwitchPlan in</span><span>
</span><span id="line-25"></span><span class="hs-comment">-- GHC.Cmm.Switch and returned as a SwitchPlan; here is just the implementation in</span><span>
</span><span id="line-26"></span><span class="hs-comment">-- terms of Cmm code. See Note [Cmm Switches, the general plan] in GHC.Cmm.Switch.</span><span>
</span><span id="line-27"></span><span class="hs-comment">--</span><span>
</span><span id="line-28"></span><span class="hs-comment">-- This division into different modules is both to clearly separate concerns,</span><span>
</span><span id="line-29"></span><span class="hs-comment">-- but also because createSwitchPlan needs access to the constructors of</span><span>
</span><span id="line-30"></span><span class="hs-comment">-- SwitchTargets, a data type exported abstractly by GHC.Cmm.Switch.</span><span>
</span><span id="line-31"></span><span class="hs-comment">--</span><span>
</span><span id="line-32"></span><span>
</span><span id="line-33"></span><span class="hs-comment">-- | Traverses the 'CmmGraph', making sure that 'CmmSwitch' are suitable for</span><span>
</span><span id="line-34"></span><span class="hs-comment">-- code generation.</span><span>
</span><span id="line-35"></span><span class="annot"><a href="GHC.Cmm.Switch.Implement.html#cmmImplementSwitchPlans"><span class="hs-identifier hs-type">cmmImplementSwitchPlans</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.html#CmmGraph"><span class="hs-identifier hs-type">CmmGraph</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html#UniqSM"><span class="hs-identifier hs-type">UniqSM</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.html#CmmGraph"><span class="hs-identifier hs-type">CmmGraph</span></a></span><span>
</span><span id="line-36"></span><span id="cmmImplementSwitchPlans"><span class="annot"><span class="annottext">cmmImplementSwitchPlans :: DynFlags -&gt; CmmGraph -&gt; UniqSM CmmGraph
</span><a href="GHC.Cmm.Switch.Implement.html#cmmImplementSwitchPlans"><span class="hs-identifier hs-var hs-var">cmmImplementSwitchPlans</span></a></span></span><span> </span><span id="local-6989586621681013630"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681013630"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681013629"><span class="annot"><span class="annottext">CmmGraph
</span><a href="#local-6989586621681013629"><span class="hs-identifier hs-var">g</span></a></span></span><span>
</span><span id="line-37"></span><span>    </span><span class="hs-comment">-- Switch generation done by backend (LLVM/C)</span><span>
</span><span id="line-38"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">HscTarget -&gt; Bool
</span><a href="GHC.Cmm.Switch.html#targetSupportsSwitch"><span class="hs-identifier hs-var">targetSupportsSwitch</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; HscTarget
</span><a href="GHC.Driver.Session.html#hscTarget"><span class="hs-identifier hs-var hs-var">hscTarget</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681013630"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmGraph -&gt; UniqSM CmmGraph
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CmmGraph
</span><a href="#local-6989586621681013629"><span class="hs-identifier hs-var">g</span></a></span><span>
</span><span id="line-39"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-40"></span><span>    </span><span id="local-6989586621681013626"><span class="annot"><span class="annottext">[CmmBlock]
</span><a href="#local-6989586621681013626"><span class="hs-identifier hs-var">blocks'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(CmmBlock -&gt; UniqSM [CmmBlock]) -&gt; [CmmBlock] -&gt; UniqSM [CmmBlock]
forall (m :: * -&gt; *) a b. Monad m =&gt; (a -&gt; m [b]) -&gt; [a] -&gt; m [b]
</span><a href="GHC.Utils.Monad.html#concatMapM"><span class="hs-identifier hs-var">concatMapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmBlock -&gt; UniqSM [CmmBlock]
</span><a href="GHC.Cmm.Switch.Implement.html#visitSwitches"><span class="hs-identifier hs-var">visitSwitches</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681013630"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmGraph -&gt; [CmmBlock]
</span><a href="GHC.Cmm.Utils.html#toBlockList"><span class="hs-identifier hs-var">toBlockList</span></a></span><span> </span><span class="annot"><span class="annottext">CmmGraph
</span><a href="#local-6989586621681013629"><span class="hs-identifier hs-var">g</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-41"></span><span>    </span><span class="annot"><span class="annottext">CmmGraph -&gt; UniqSM CmmGraph
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmGraph -&gt; UniqSM CmmGraph) -&gt; CmmGraph -&gt; UniqSM CmmGraph
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; [CmmBlock] -&gt; CmmGraph
</span><a href="GHC.Cmm.Utils.html#ofBlockList"><span class="hs-identifier hs-var">ofBlockList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmGraph -&gt; BlockId
forall (n :: Extensibility -&gt; Extensibility -&gt; *).
GenCmmGraph n -&gt; BlockId
</span><a href="GHC.Cmm.html#g_entry"><span class="hs-identifier hs-var hs-var">g_entry</span></a></span><span> </span><span class="annot"><span class="annottext">CmmGraph
</span><a href="#local-6989586621681013629"><span class="hs-identifier hs-var">g</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CmmBlock]
</span><a href="#local-6989586621681013626"><span class="hs-identifier hs-var">blocks'</span></a></span><span>
</span><span id="line-42"></span><span>
</span><span id="line-43"></span><span class="annot"><a href="GHC.Cmm.Switch.Implement.html#visitSwitches"><span class="hs-identifier hs-type">visitSwitches</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.html#CmmBlock"><span class="hs-identifier hs-type">CmmBlock</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html#UniqSM"><span class="hs-identifier hs-type">UniqSM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.html#CmmBlock"><span class="hs-identifier hs-type">CmmBlock</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-44"></span><span id="visitSwitches"><span class="annot"><span class="annottext">visitSwitches :: Platform -&gt; CmmBlock -&gt; UniqSM [CmmBlock]
</span><a href="GHC.Cmm.Switch.Implement.html#visitSwitches"><span class="hs-identifier hs-var hs-var">visitSwitches</span></a></span></span><span> </span><span id="local-6989586621681013620"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681013620"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span id="local-6989586621681013619"><span class="annot"><span class="annottext">CmmBlock
</span><a href="#local-6989586621681013619"><span class="hs-identifier hs-var">block</span></a></span></span><span>
</span><span id="line-45"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681013618"><span class="annot"><span class="annottext">entry :: CmmNode C O
</span><a href="#local-6989586621681013618"><span class="hs-identifier hs-var">entry</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Node.html#CmmEntry"><span class="hs-identifier hs-type">CmmEntry</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681013614"><span class="annot"><span class="annottext">CmmTickScope
</span><a href="#local-6989586621681013614"><span class="hs-identifier hs-var">scope</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span id="local-6989586621681013613"><span class="annot"><span class="annottext">Block CmmNode O O
</span><a href="#local-6989586621681013613"><span class="hs-identifier hs-var">middle</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmSwitch"><span class="hs-identifier hs-type">CmmSwitch</span></a></span><span> </span><span id="local-6989586621681013606"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681013606"><span class="hs-identifier hs-var">vanillaExpr</span></a></span></span><span> </span><span id="local-6989586621681013605"><span class="annot"><span class="annottext">SwitchTargets
</span><a href="#local-6989586621681013605"><span class="hs-identifier hs-var">ids</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CmmBlock -&gt; (CmmNode C O, Block CmmNode O O, CmmNode O C)
forall (n :: Extensibility -&gt; Extensibility -&gt; *).
Block n C C -&gt; (n C O, Block n O O, n O C)
</span><a href="GHC.Cmm.Dataflow.Block.html#blockSplit"><span class="hs-identifier hs-var">blockSplit</span></a></span><span> </span><span class="annot"><span class="annottext">CmmBlock
</span><a href="#local-6989586621681013619"><span class="hs-identifier hs-var">block</span></a></span><span>
</span><span id="line-46"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-47"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681013603"><span class="annot"><span class="annottext">plan :: SwitchPlan
</span><a href="#local-6989586621681013603"><span class="hs-identifier hs-var hs-var">plan</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SwitchTargets -&gt; SwitchPlan
</span><a href="GHC.Cmm.Switch.html#createSwitchPlan"><span class="hs-identifier hs-var">createSwitchPlan</span></a></span><span> </span><span class="annot"><span class="annottext">SwitchTargets
</span><a href="#local-6989586621681013605"><span class="hs-identifier hs-var">ids</span></a></span><span>
</span><span id="line-48"></span><span>    </span><span class="hs-comment">-- See Note [Floating switch expressions]</span><span>
</span><span id="line-49"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681013601"><span class="annot"><span class="annottext">Block CmmNode O O
</span><a href="#local-6989586621681013601"><span class="hs-identifier hs-var">assignSimple</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681013600"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681013600"><span class="hs-identifier hs-var">simpleExpr</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; UniqSM (Block CmmNode O O, CmmExpr)
</span><a href="GHC.Cmm.Switch.Implement.html#floatSwitchExpr"><span class="hs-identifier hs-var">floatSwitchExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681013620"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681013606"><span class="hs-identifier hs-var">vanillaExpr</span></a></span><span>
</span><span id="line-50"></span><span>
</span><span id="line-51"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681013598"><span class="annot"><span class="annottext">Block CmmNode O C
</span><a href="#local-6989586621681013598"><span class="hs-identifier hs-var">newTail</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681013597"><span class="annot"><span class="annottext">[CmmBlock]
</span><a href="#local-6989586621681013597"><span class="hs-identifier hs-var">newBlocks</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Platform
-&gt; CmmTickScope
-&gt; CmmExpr
-&gt; SwitchPlan
-&gt; UniqSM (Block CmmNode O C, [CmmBlock])
</span><a href="GHC.Cmm.Switch.Implement.html#implementSwitchPlan"><span class="hs-identifier hs-var">implementSwitchPlan</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681013620"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmTickScope
</span><a href="#local-6989586621681013614"><span class="hs-identifier hs-var">scope</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681013600"><span class="hs-identifier hs-var">simpleExpr</span></a></span><span> </span><span class="annot"><span class="annottext">SwitchPlan
</span><a href="#local-6989586621681013603"><span class="hs-identifier hs-var">plan</span></a></span><span>
</span><span id="line-52"></span><span>
</span><span id="line-53"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681013595"><span class="annot"><span class="annottext">block' :: CmmBlock
</span><a href="#local-6989586621681013595"><span class="hs-identifier hs-var hs-var">block'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmNode C O
</span><a href="#local-6989586621681013618"><span class="hs-identifier hs-var">entry</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode C O -&gt; Block CmmNode O O -&gt; Block CmmNode C O
forall (n :: Extensibility -&gt; Extensibility -&gt; *)
       (x :: Extensibility).
n C O -&gt; Block n O x -&gt; Block n C x
</span><a href="GHC.Cmm.Dataflow.Block.html#blockJoinHead"><span class="hs-operator hs-var">`blockJoinHead`</span></a></span><span> </span><span class="annot"><span class="annottext">Block CmmNode O O
</span><a href="#local-6989586621681013613"><span class="hs-identifier hs-var">middle</span></a></span><span> </span><span class="annot"><span class="annottext">Block CmmNode C O -&gt; Block CmmNode O O -&gt; Block CmmNode C O
forall (n :: Extensibility -&gt; Extensibility -&gt; *)
       (e :: Extensibility) (x :: Extensibility).
Block n e O -&gt; Block n O x -&gt; Block n e x
</span><a href="GHC.Cmm.Dataflow.Block.html#blockAppend"><span class="hs-operator hs-var">`blockAppend`</span></a></span><span> </span><span class="annot"><span class="annottext">Block CmmNode O O
</span><a href="#local-6989586621681013601"><span class="hs-identifier hs-var">assignSimple</span></a></span><span> </span><span class="annot"><span class="annottext">Block CmmNode C O -&gt; Block CmmNode O C -&gt; CmmBlock
forall (n :: Extensibility -&gt; Extensibility -&gt; *)
       (e :: Extensibility) (x :: Extensibility).
Block n e O -&gt; Block n O x -&gt; Block n e x
</span><a href="GHC.Cmm.Dataflow.Block.html#blockAppend"><span class="hs-operator hs-var">`blockAppend`</span></a></span><span> </span><span class="annot"><span class="annottext">Block CmmNode O C
</span><a href="#local-6989586621681013598"><span class="hs-identifier hs-var">newTail</span></a></span><span>
</span><span id="line-54"></span><span>
</span><span id="line-55"></span><span>    </span><span class="annot"><span class="annottext">[CmmBlock] -&gt; UniqSM [CmmBlock]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">([CmmBlock] -&gt; UniqSM [CmmBlock])
-&gt; [CmmBlock] -&gt; UniqSM [CmmBlock]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CmmBlock
</span><a href="#local-6989586621681013595"><span class="hs-identifier hs-var">block'</span></a></span><span> </span><span class="annot"><span class="annottext">CmmBlock -&gt; [CmmBlock] -&gt; [CmmBlock]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[CmmBlock]
</span><a href="#local-6989586621681013597"><span class="hs-identifier hs-var">newBlocks</span></a></span><span>
</span><span id="line-56"></span><span>
</span><span id="line-57"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-58"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CmmBlock] -&gt; UniqSM [CmmBlock]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CmmBlock
</span><a href="#local-6989586621681013619"><span class="hs-identifier hs-var">block</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-59"></span><span>
</span><span id="line-60"></span><span class="hs-comment">-- Note [Floating switch expressions]</span><span>
</span><span id="line-61"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-62"></span><span>
</span><span id="line-63"></span><span class="hs-comment">-- When we translate a sparse switch into a search tree we would like</span><span>
</span><span id="line-64"></span><span class="hs-comment">-- to compute the value we compare against only once.</span><span>
</span><span id="line-65"></span><span>
</span><span id="line-66"></span><span class="hs-comment">-- For this purpose we assign the switch expression to a local register</span><span>
</span><span id="line-67"></span><span class="hs-comment">-- and then use this register when constructing the actual binary tree.</span><span>
</span><span id="line-68"></span><span>
</span><span id="line-69"></span><span class="hs-comment">-- This is important as the expression could contain expensive code like</span><span>
</span><span id="line-70"></span><span class="hs-comment">-- memory loads or divisions which we REALLY don't want to duplicate.</span><span>
</span><span id="line-71"></span><span>
</span><span id="line-72"></span><span class="hs-comment">-- This happened in parts of the handwritten RTS Cmm code. See also #16933</span><span>
</span><span id="line-73"></span><span>
</span><span id="line-74"></span><span class="hs-comment">-- See Note [Floating switch expressions]</span><span>
</span><span id="line-75"></span><span class="annot"><a href="GHC.Cmm.Switch.Implement.html#floatSwitchExpr"><span class="hs-identifier hs-type">floatSwitchExpr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html#UniqSM"><span class="hs-identifier hs-type">UniqSM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#Block"><span class="hs-identifier hs-type">Block</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmNode"><span class="hs-identifier hs-type">CmmNode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-76"></span><span id="floatSwitchExpr"><span class="annot"><span class="annottext">floatSwitchExpr :: Platform -&gt; CmmExpr -&gt; UniqSM (Block CmmNode O O, CmmExpr)
</span><a href="GHC.Cmm.Switch.Implement.html#floatSwitchExpr"><span class="hs-identifier hs-var hs-var">floatSwitchExpr</span></a></span></span><span> </span><span class="annot"><span class="annottext">Platform
</span><span class="hs-identifier">_</span></span><span>        </span><span id="local-6989586621681013592"><span class="annot"><span class="annottext">reg :: CmmExpr
</span><a href="#local-6989586621681013592"><span class="hs-identifier hs-var">reg</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-type">CmmReg</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Block CmmNode O O, CmmExpr) -&gt; UniqSM (Block CmmNode O O, CmmExpr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Block CmmNode O O
forall (n :: Extensibility -&gt; Extensibility -&gt; *). Block n O O
</span><a href="GHC.Cmm.Dataflow.Block.html#emptyBlock"><span class="hs-identifier hs-var">emptyBlock</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681013592"><span class="hs-identifier hs-var">reg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-77"></span><span class="annot"><a href="GHC.Cmm.Switch.Implement.html#floatSwitchExpr"><span class="hs-identifier hs-var">floatSwitchExpr</span></a></span><span> </span><span id="local-6989586621681013589"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681013589"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span id="local-6989586621681013588"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681013588"><span class="hs-identifier hs-var">expr</span></a></span></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-78"></span><span>  </span><span class="hs-special">(</span><span id="local-6989586621681013587"><span class="annot"><span class="annottext">CmmNode O O
</span><a href="#local-6989586621681013587"><span class="hs-identifier hs-var">assign</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681013586"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681013586"><span class="hs-identifier hs-var">expr'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; Unique -&gt; (CmmNode O O, CmmExpr)
</span><a href="GHC.Cmm.Utils.html#cmmMkAssign"><span class="hs-identifier hs-var">cmmMkAssign</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681013589"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681013588"><span class="hs-identifier hs-var">expr</span></a></span><span> </span><span class="annot"><span class="annottext">(Unique -&gt; (CmmNode O O, CmmExpr))
-&gt; UniqSM Unique -&gt; UniqSM (CmmNode O O, CmmExpr)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSM Unique
forall (m :: * -&gt; *). MonadUnique m =&gt; m Unique
</span><a href="GHC.Types.Unique.Supply.html#getUniqueM"><span class="hs-identifier hs-var">getUniqueM</span></a></span><span>
</span><span id="line-79"></span><span>  </span><span class="annot"><span class="annottext">(Block CmmNode O O, CmmExpr) -&gt; UniqSM (Block CmmNode O O, CmmExpr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmNode O O -&gt; Block CmmNode O O
forall (n :: Extensibility -&gt; Extensibility -&gt; *).
n O O -&gt; Block n O O
</span><a href="GHC.Cmm.Dataflow.Block.html#BMiddle"><span class="hs-identifier hs-var">BMiddle</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O O
</span><a href="#local-6989586621681013587"><span class="hs-identifier hs-var">assign</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681013586"><span class="hs-identifier hs-var">expr'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-80"></span><span>
</span><span id="line-81"></span><span>
</span><span id="line-82"></span><span class="hs-comment">-- Implementing a switch plan (returning a tail block)</span><span>
</span><span id="line-83"></span><span class="annot"><a href="GHC.Cmm.Switch.Implement.html#implementSwitchPlan"><span class="hs-identifier hs-type">implementSwitchPlan</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmTickScope"><span class="hs-identifier hs-type">CmmTickScope</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Switch.html#SwitchPlan"><span class="hs-identifier hs-type">SwitchPlan</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html#UniqSM"><span class="hs-identifier hs-type">UniqSM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#Block"><span class="hs-identifier hs-type">Block</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#CmmNode"><span class="hs-identifier hs-type">CmmNode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#O"><span class="hs-identifier hs-type">O</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Block.html#C"><span class="hs-identifier hs-type">C</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.html#CmmBlock"><span class="hs-identifier hs-type">CmmBlock</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-84"></span><span id="implementSwitchPlan"><span class="annot"><span class="annottext">implementSwitchPlan :: Platform
-&gt; CmmTickScope
-&gt; CmmExpr
-&gt; SwitchPlan
-&gt; UniqSM (Block CmmNode O C, [CmmBlock])
</span><a href="GHC.Cmm.Switch.Implement.html#implementSwitchPlan"><span class="hs-identifier hs-var hs-var">implementSwitchPlan</span></a></span></span><span> </span><span id="local-6989586621681013581"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681013581"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span id="local-6989586621681013580"><span class="annot"><span class="annottext">CmmTickScope
</span><a href="#local-6989586621681013580"><span class="hs-identifier hs-var">scope</span></a></span></span><span> </span><span id="local-6989586621681013579"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681013579"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SwitchPlan -&gt; UniqSM (Block CmmNode O C, [CmmBlock])
</span><a href="#local-6989586621681013578"><span class="hs-identifier hs-var">go</span></a></span><span>
</span><span id="line-85"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-86"></span><span>    </span><span id="local-6989586621681013578"><span class="annot"><span class="annottext">go :: SwitchPlan -&gt; UniqSM (Block CmmNode O C, [CmmBlock])
</span><a href="#local-6989586621681013578"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Switch.html#Unconditionally"><span class="hs-identifier hs-type">Unconditionally</span></a></span><span> </span><span id="local-6989586621681013576"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681013576"><span class="hs-identifier hs-var">l</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-87"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Block CmmNode O C, [CmmBlock])
-&gt; UniqSM (Block CmmNode O C, [CmmBlock])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Block CmmNode O O
forall (n :: Extensibility -&gt; Extensibility -&gt; *). Block n O O
</span><a href="GHC.Cmm.Dataflow.Block.html#emptyBlock"><span class="hs-identifier hs-var">emptyBlock</span></a></span><span> </span><span class="annot"><span class="annottext">Block CmmNode O O -&gt; CmmNode O C -&gt; Block CmmNode O C
forall (n :: Extensibility -&gt; Extensibility -&gt; *)
       (e :: Extensibility).
Block n e O -&gt; n O C -&gt; Block n e C
</span><a href="GHC.Cmm.Dataflow.Block.html#blockJoinTail"><span class="hs-operator hs-var">`blockJoinTail`</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; CmmNode O C
</span><a href="GHC.Cmm.Node.html#CmmBranch"><span class="hs-identifier hs-var">CmmBranch</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681013576"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-88"></span><span>    </span><span class="annot"><a href="#local-6989586621681013578"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Switch.html#JumpTable"><span class="hs-identifier hs-type">JumpTable</span></a></span><span> </span><span id="local-6989586621681013572"><span class="annot"><span class="annottext">SwitchTargets
</span><a href="#local-6989586621681013572"><span class="hs-identifier hs-var">ids</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-89"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Block CmmNode O C, [CmmBlock])
-&gt; UniqSM (Block CmmNode O C, [CmmBlock])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Block CmmNode O O
forall (n :: Extensibility -&gt; Extensibility -&gt; *). Block n O O
</span><a href="GHC.Cmm.Dataflow.Block.html#emptyBlock"><span class="hs-identifier hs-var">emptyBlock</span></a></span><span> </span><span class="annot"><span class="annottext">Block CmmNode O O -&gt; CmmNode O C -&gt; Block CmmNode O C
forall (n :: Extensibility -&gt; Extensibility -&gt; *)
       (e :: Extensibility).
Block n e O -&gt; n O C -&gt; Block n e C
</span><a href="GHC.Cmm.Dataflow.Block.html#blockJoinTail"><span class="hs-operator hs-var">`blockJoinTail`</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; SwitchTargets -&gt; CmmNode O C
</span><a href="GHC.Cmm.Node.html#CmmSwitch"><span class="hs-identifier hs-var">CmmSwitch</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681013579"><span class="hs-identifier hs-var">expr</span></a></span><span> </span><span class="annot"><span class="annottext">SwitchTargets
</span><a href="#local-6989586621681013572"><span class="hs-identifier hs-var">ids</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-90"></span><span>    </span><span class="annot"><a href="#local-6989586621681013578"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Switch.html#IfLT"><span class="hs-identifier hs-type">IfLT</span></a></span><span> </span><span id="local-6989586621681013570"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681013570"><span class="hs-identifier hs-var">signed</span></a></span></span><span> </span><span id="local-6989586621681013569"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621681013569"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span id="local-6989586621681013568"><span class="annot"><span class="annottext">SwitchPlan
</span><a href="#local-6989586621681013568"><span class="hs-identifier hs-var">ids1</span></a></span></span><span> </span><span id="local-6989586621681013567"><span class="annot"><span class="annottext">SwitchPlan
</span><a href="#local-6989586621681013567"><span class="hs-identifier hs-var">ids2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-91"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-92"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621681013566"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681013566"><span class="hs-identifier hs-var">bid1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681013565"><span class="annot"><span class="annottext">[CmmBlock]
</span><a href="#local-6989586621681013565"><span class="hs-identifier hs-var">newBlocks1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SwitchPlan -&gt; UniqSM (BlockId, [CmmBlock])
</span><a href="#local-6989586621681013564"><span class="hs-identifier hs-var">go'</span></a></span><span> </span><span class="annot"><span class="annottext">SwitchPlan
</span><a href="#local-6989586621681013568"><span class="hs-identifier hs-var">ids1</span></a></span><span>
</span><span id="line-93"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621681013563"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681013563"><span class="hs-identifier hs-var">bid2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681013562"><span class="annot"><span class="annottext">[CmmBlock]
</span><a href="#local-6989586621681013562"><span class="hs-identifier hs-var">newBlocks2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SwitchPlan -&gt; UniqSM (BlockId, [CmmBlock])
</span><a href="#local-6989586621681013564"><span class="hs-identifier hs-var">go'</span></a></span><span> </span><span class="annot"><span class="annottext">SwitchPlan
</span><a href="#local-6989586621681013567"><span class="hs-identifier hs-var">ids2</span></a></span><span>
</span><span id="line-94"></span><span>
</span><span id="line-95"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681013561"><span class="annot"><span class="annottext">lt :: Platform -&gt; CmmExpr -&gt; CmmExpr -&gt; CmmExpr
</span><a href="#local-6989586621681013561"><span class="hs-identifier hs-var hs-var">lt</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681013570"><span class="hs-identifier hs-var">signed</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; CmmExpr -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmSLtWord"><span class="hs-identifier hs-var">cmmSLtWord</span></a></span><span>
</span><span id="line-96"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; CmmExpr -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmULtWord"><span class="hs-identifier hs-var">cmmULtWord</span></a></span><span>
</span><span id="line-97"></span><span>            </span><span id="local-6989586621681013558"><span class="annot"><span class="annottext">scrut :: CmmExpr
</span><a href="#local-6989586621681013558"><span class="hs-identifier hs-var hs-var">scrut</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; CmmExpr -&gt; CmmExpr
</span><a href="#local-6989586621681013561"><span class="hs-identifier hs-var">lt</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681013581"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681013579"><span class="hs-identifier hs-var">expr</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmExpr -&gt; CmmExpr) -&gt; CmmExpr -&gt; CmmExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CmmLit -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmLit"><span class="hs-identifier hs-var">CmmLit</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmLit -&gt; CmmExpr) -&gt; CmmLit -&gt; CmmExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Integer -&gt; CmmLit
</span><a href="GHC.Cmm.Utils.html#mkWordCLit"><span class="hs-identifier hs-var">mkWordCLit</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681013581"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621681013569"><span class="hs-identifier hs-var">i</span></a></span><span>
</span><span id="line-98"></span><span>            </span><span id="local-6989586621681013555"><span class="annot"><span class="annottext">lastNode :: CmmNode O C
</span><a href="#local-6989586621681013555"><span class="hs-identifier hs-var hs-var">lastNode</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; BlockId -&gt; BlockId -&gt; Maybe Bool -&gt; CmmNode O C
</span><a href="GHC.Cmm.Node.html#CmmCondBranch"><span class="hs-identifier hs-var">CmmCondBranch</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681013558"><span class="hs-identifier hs-var">scrut</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681013566"><span class="hs-identifier hs-var">bid1</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681013563"><span class="hs-identifier hs-var">bid2</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Bool
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-99"></span><span>            </span><span id="local-6989586621681013553"><span class="annot"><span class="annottext">lastBlock :: Block CmmNode O C
</span><a href="#local-6989586621681013553"><span class="hs-identifier hs-var hs-var">lastBlock</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Block CmmNode O O
forall (n :: Extensibility -&gt; Extensibility -&gt; *). Block n O O
</span><a href="GHC.Cmm.Dataflow.Block.html#emptyBlock"><span class="hs-identifier hs-var">emptyBlock</span></a></span><span> </span><span class="annot"><span class="annottext">Block CmmNode O O -&gt; CmmNode O C -&gt; Block CmmNode O C
forall (n :: Extensibility -&gt; Extensibility -&gt; *)
       (e :: Extensibility).
Block n e O -&gt; n O C -&gt; Block n e C
</span><a href="GHC.Cmm.Dataflow.Block.html#blockJoinTail"><span class="hs-operator hs-var">`blockJoinTail`</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O C
</span><a href="#local-6989586621681013555"><span class="hs-identifier hs-var">lastNode</span></a></span><span>
</span><span id="line-100"></span><span>        </span><span class="annot"><span class="annottext">(Block CmmNode O C, [CmmBlock])
-&gt; UniqSM (Block CmmNode O C, [CmmBlock])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Block CmmNode O C
</span><a href="#local-6989586621681013553"><span class="hs-identifier hs-var">lastBlock</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[CmmBlock]
</span><a href="#local-6989586621681013565"><span class="hs-identifier hs-var">newBlocks1</span></a></span><span class="annot"><span class="annottext">[CmmBlock] -&gt; [CmmBlock] -&gt; [CmmBlock]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span class="annot"><span class="annottext">[CmmBlock]
</span><a href="#local-6989586621681013562"><span class="hs-identifier hs-var">newBlocks2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-101"></span><span>    </span><span class="annot"><a href="#local-6989586621681013578"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Switch.html#IfEqual"><span class="hs-identifier hs-type">IfEqual</span></a></span><span> </span><span id="local-6989586621681013551"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621681013551"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span id="local-6989586621681013550"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681013550"><span class="hs-identifier hs-var">l</span></a></span></span><span> </span><span id="local-6989586621681013549"><span class="annot"><span class="annottext">SwitchPlan
</span><a href="#local-6989586621681013549"><span class="hs-identifier hs-var">ids2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-102"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-103"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621681013548"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681013548"><span class="hs-identifier hs-var">bid2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681013547"><span class="annot"><span class="annottext">[CmmBlock]
</span><a href="#local-6989586621681013547"><span class="hs-identifier hs-var">newBlocks2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SwitchPlan -&gt; UniqSM (BlockId, [CmmBlock])
</span><a href="#local-6989586621681013564"><span class="hs-identifier hs-var">go'</span></a></span><span> </span><span class="annot"><span class="annottext">SwitchPlan
</span><a href="#local-6989586621681013549"><span class="hs-identifier hs-var">ids2</span></a></span><span>
</span><span id="line-104"></span><span>
</span><span id="line-105"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681013546"><span class="annot"><span class="annottext">scrut :: CmmExpr
</span><a href="#local-6989586621681013546"><span class="hs-identifier hs-var hs-var">scrut</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; CmmExpr -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmNeWord"><span class="hs-identifier hs-var">cmmNeWord</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681013581"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681013579"><span class="hs-identifier hs-var">expr</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmExpr -&gt; CmmExpr) -&gt; CmmExpr -&gt; CmmExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CmmLit -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmLit"><span class="hs-identifier hs-var">CmmLit</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmLit -&gt; CmmExpr) -&gt; CmmLit -&gt; CmmExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Integer -&gt; CmmLit
</span><a href="GHC.Cmm.Utils.html#mkWordCLit"><span class="hs-identifier hs-var">mkWordCLit</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681013581"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621681013551"><span class="hs-identifier hs-var">i</span></a></span><span>
</span><span id="line-106"></span><span>            </span><span id="local-6989586621681013544"><span class="annot"><span class="annottext">lastNode :: CmmNode O C
</span><a href="#local-6989586621681013544"><span class="hs-identifier hs-var hs-var">lastNode</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; BlockId -&gt; BlockId -&gt; Maybe Bool -&gt; CmmNode O C
</span><a href="GHC.Cmm.Node.html#CmmCondBranch"><span class="hs-identifier hs-var">CmmCondBranch</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681013546"><span class="hs-identifier hs-var">scrut</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681013548"><span class="hs-identifier hs-var">bid2</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681013550"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Bool
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-107"></span><span>            </span><span id="local-6989586621681013543"><span class="annot"><span class="annottext">lastBlock :: Block CmmNode O C
</span><a href="#local-6989586621681013543"><span class="hs-identifier hs-var hs-var">lastBlock</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Block CmmNode O O
forall (n :: Extensibility -&gt; Extensibility -&gt; *). Block n O O
</span><a href="GHC.Cmm.Dataflow.Block.html#emptyBlock"><span class="hs-identifier hs-var">emptyBlock</span></a></span><span> </span><span class="annot"><span class="annottext">Block CmmNode O O -&gt; CmmNode O C -&gt; Block CmmNode O C
forall (n :: Extensibility -&gt; Extensibility -&gt; *)
       (e :: Extensibility).
Block n e O -&gt; n O C -&gt; Block n e C
</span><a href="GHC.Cmm.Dataflow.Block.html#blockJoinTail"><span class="hs-operator hs-var">`blockJoinTail`</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O C
</span><a href="#local-6989586621681013544"><span class="hs-identifier hs-var">lastNode</span></a></span><span>
</span><span id="line-108"></span><span>        </span><span class="annot"><span class="annottext">(Block CmmNode O C, [CmmBlock])
-&gt; UniqSM (Block CmmNode O C, [CmmBlock])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Block CmmNode O C
</span><a href="#local-6989586621681013543"><span class="hs-identifier hs-var">lastBlock</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[CmmBlock]
</span><a href="#local-6989586621681013547"><span class="hs-identifier hs-var">newBlocks2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-109"></span><span>
</span><span id="line-110"></span><span>    </span><span class="hs-comment">-- Same but returning a label to branch to</span><span>
</span><span id="line-111"></span><span>    </span><span id="local-6989586621681013564"><span class="annot"><span class="annottext">go' :: SwitchPlan -&gt; UniqSM (BlockId, [CmmBlock])
</span><a href="#local-6989586621681013564"><span class="hs-identifier hs-var hs-var">go'</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Switch.html#Unconditionally"><span class="hs-identifier hs-type">Unconditionally</span></a></span><span> </span><span id="local-6989586621681013542"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681013542"><span class="hs-identifier hs-var">l</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-112"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(BlockId, [CmmBlock]) -&gt; UniqSM (BlockId, [CmmBlock])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681013542"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-113"></span><span>    </span><span class="annot"><a href="#local-6989586621681013564"><span class="hs-identifier hs-var">go'</span></a></span><span> </span><span id="local-6989586621681013541"><span class="annot"><span class="annottext">SwitchPlan
</span><a href="#local-6989586621681013541"><span class="hs-identifier hs-var">p</span></a></span></span><span>
</span><span id="line-114"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-115"></span><span>        </span><span id="local-6989586621681013540"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681013540"><span class="hs-identifier hs-var">bid</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Unique -&gt; BlockId
</span><a href="GHC.Cmm.BlockId.html#mkBlockId"><span class="hs-identifier hs-var">mkBlockId</span></a></span><span> </span><span class="annot"><span class="annottext">(Unique -&gt; BlockId) -&gt; UniqSM Unique -&gt; UniqSM BlockId
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-operator hs-var">`fmap`</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSM Unique
forall (m :: * -&gt; *). MonadUnique m =&gt; m Unique
</span><a href="GHC.Types.Unique.Supply.html#getUniqueM"><span class="hs-identifier hs-var">getUniqueM</span></a></span><span>
</span><span id="line-116"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621681013538"><span class="annot"><span class="annottext">Block CmmNode O C
</span><a href="#local-6989586621681013538"><span class="hs-identifier hs-var">last</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681013537"><span class="annot"><span class="annottext">[CmmBlock]
</span><a href="#local-6989586621681013537"><span class="hs-identifier hs-var">newBlocks</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SwitchPlan -&gt; UniqSM (Block CmmNode O C, [CmmBlock])
</span><a href="#local-6989586621681013578"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">SwitchPlan
</span><a href="#local-6989586621681013541"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-117"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681013536"><span class="annot"><span class="annottext">block :: CmmBlock
</span><a href="#local-6989586621681013536"><span class="hs-identifier hs-var hs-var">block</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; CmmTickScope -&gt; CmmNode C O
</span><a href="GHC.Cmm.Node.html#CmmEntry"><span class="hs-identifier hs-var">CmmEntry</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681013540"><span class="hs-identifier hs-var">bid</span></a></span><span> </span><span class="annot"><span class="annottext">CmmTickScope
</span><a href="#local-6989586621681013580"><span class="hs-identifier hs-var">scope</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode C O -&gt; Block CmmNode O C -&gt; CmmBlock
forall (n :: Extensibility -&gt; Extensibility -&gt; *)
       (x :: Extensibility).
n C O -&gt; Block n O x -&gt; Block n C x
</span><a href="GHC.Cmm.Dataflow.Block.html#blockJoinHead"><span class="hs-operator hs-var">`blockJoinHead`</span></a></span><span> </span><span class="annot"><span class="annottext">Block CmmNode O C
</span><a href="#local-6989586621681013538"><span class="hs-identifier hs-var">last</span></a></span><span>
</span><span id="line-118"></span><span>        </span><span class="annot"><span class="annottext">(BlockId, [CmmBlock]) -&gt; UniqSM (BlockId, [CmmBlock])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681013540"><span class="hs-identifier hs-var">bid</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CmmBlock
</span><a href="#local-6989586621681013536"><span class="hs-identifier hs-var">block</span></a></span><span class="annot"><span class="annottext">CmmBlock -&gt; [CmmBlock] -&gt; [CmmBlock]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[CmmBlock]
</span><a href="#local-6989586621681013537"><span class="hs-identifier hs-var">newBlocks</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-119"></span></pre></body></html>